home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DDJMAG
/
DDJ8801.ZIP
/
LETTER.ZIP
/
LETTER.EXP
Wrap
Text File
|
1987-10-19
|
2KB
|
84 lines
procedure Try(1: integer);
begin
for q[1] := 0 to maxcount do begin
if fit(1) then begin
place(1);
if 1 = max then ShowResult
else try(1 + 1);
unplace(1);
end;
end;
end;
{ Main Program }
begin
initialize;
try(0);
end.
Example 1: Eight queens problem in Pascal
Program test;
procedure bump(n: integer);
begin
writeln(n);
bump(n + 1);
end
{ Main Program }
begin
bump(0);
end.
Example 2: Program to test levels of procedure nesting
254 10 UNITS INCHES
254 12 * 10 UNITS FEET
254 36 * 10 UNITS YARDS
10 1 UNITS CENTIMETERS
1000 1 UNITS METERS
\ Usage:
10 FEET . <cr> 3048 ok
3 METERS . <cr> 3000 ok
\ ........................
\ etc.
Example 3: Conversion program using the defining word UNITS
VARIABLE <AS> 0 <AS> !
: AS -1 <AS> ! ;
: UNITS CREATE SWAP , , DOES> D@ <AS> @
IF SWAP THEN */ 0 <AS> ! ;
BEHEAD' <AS> \ TO MAKE IT LOCAL FOR SECURITY
\ UNIT DEFINITIONS REMAIN THE SAME.
\ Usage:
10 FEET . <cr> 3048 ok
3048 AS FEET . <cr> 10 ok
Example 4: Code to convert back to input units when outputting
Bytes 8088 Clocks
----- -----------------
3 12+ea = 12+9 = 21 mov ax,word ptr {bp}.value
2 2 mov bx,ax
3 12+ea = 12+9 = 21 mov ax,word ptr {bp}.value{2}
----- -----------------
8 44
3 12+ea = 12+9 = 21 mov ax,word ptr {bp}.value{2}
3 12+ea = 12+9 = 21 mov bx,word ptr {bp}.value
----- -----------------
6 42
3 24+ea = 24+9 = 33 les bx,{bp}.value
2 2 mov ax,es
----- -----------------
5 35
Table 1: Timings for Example 6, page 26, July 1987 issue of DDJ